﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace Corina.Logis
{
    public class LogMessage
    {
        /// <summary>

        /// 创建新的日志记录实例;日志记录的内容为空,消息类型为MsgType.Unknown,日志时间为当前时间

        /// </summary>

        public LogMessage()
            : this("", MessageLevel.Debug)
        {

        }

 

        /// <summary>

        /// 创建新的日志记录实例;日志事件为当前时间

        /// </summary>

        /// <param name="t">日志记录的文本内容</param>

        /// <param name="p">日志记录的消息类型</param>

        public LogMessage(string t, MessageLevel p)
            : this(DateTime.Now, t, p)
        {

        }

 

        /// <summary>

        /// 创建新的日志记录实例;

        /// </summary>

        /// <param name="dt">日志记录的时间</param>

        /// <param name="t">日志记录的文本内容</param>

        /// <param name="p">日志记录的消息类型</param>

        public LogMessage(DateTime dt, string t, MessageLevel p)

        {

            datetime = dt;

            type = p;

            text = t;

        }

 

        /// <summary>

        /// 日志记录的时间

        /// </summary>

        public DateTime datetime { get; set; }

 

        /// <summary>

        ///日志记录的内容

        /// </summary>

        public string text { get; set; }

 

        /// <summary>

        /// 日志等级

        /// </summary>

        public MessageLevel type { get; set; }

 

 

        public new string ToString()

        {

            return datetime.ToString(CultureInfo.InvariantCulture) + "\t" + text + "\n";

        }

    }
}
